import 'package:base/widget/cloud/cloud_data_list.dart';
import 'package:base/widget/cloud/cloud_widget.dart';
import 'package:flutter/material.dart';

class CloudPage extends StatefulWidget {
  @override
  _CloudPageState createState() => _CloudPageState();
}

class _CloudPageState extends State<CloudPage> {
  List<CloudItemData> dataList = cloudItemDataList;

  @override
  Widget build(BuildContext context) {
    double appWidth = MediaQuery.of(context).size.width;

    return Scaffold(
      appBar: AppBar(title: Text('cloud page')),
      body: Center(
        child: Container(
          width: appWidth,
          height: appWidth,
          // 利用 fittedBox 约束 Child
          child: FittedBox(
            // Cloud 布局
            child: Container(
              padding: EdgeInsets.symmetric(vertical: 10, horizontal: 6),
              color: Colors.brown,
              // 布局
              child: CloudWidget(
                ///容器宽高比例
                ratio: 1,
                children: <Widget>[
                  for (var item in dataList)
                    // 判断是否旋转
                    RotatedBox(
                      quarterTurns: item.rotate ? 1 : 0,
                      child: Text(
                        item.text,
                        style: new TextStyle(
                          fontSize: item.size,
                          color: item.color,
                        ),
                      ),
                    ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
